#export CUDA_LAUNCH_BLOCKING=1
task_flag="inpaint_outpaint"                                # the task flag is used to identify folders.
control_type=masked  # canny              # checkpoint root for resume
resume=/root/work/filestorage/liuxin/weight/328weight/ditbase/mp_rank_00_model_states.pt # 预训练模型权重
index_file=data/train_data_bs4_node1.json                   # index file for dataloader
results_dir=/root/work/filestorage/qkd/HunyuanDIT-PRE-main/weight       # 权重保存地址
batch_size=4                                                 # training batch size
image_size=1024                                              # training image resolution
grad_accu_steps=1                                            # gradient accumulation
warmup_num_steps=0                                           # warm-up steps
lr=0.00001                                                    # learning rate
ckpt_every=500                                             # create a ckpt every a few steps.
ckpt_latest_every=5000                                       # create a ckpt named `latest.pt` every a few steps.

export PYTORCH_NPU_ALLOC_CONF="expandable_segments:True"

sh $(dirname "$0")/run_g_controlnet.sh \
    --task-flag ${task_flag} \
    --control-type ${control_type} \
    --noise-schedule scaled_linear --beta-start 0.00085 --beta-end 0.03 \
    --predict-type v_prediction \
    --reso-step 64 \
    --multireso \
    --uncond-p 0.05 \
    --uncond-p-t5 0.05 \
    --uncond-p-img 0.05 \
    --index-file ${index_file} \
    --random-flip \
    --lr ${lr} \
    --batch-size ${batch_size} \
    --image-size ${image_size} \
    --global-seed 999 \
    --grad-accu-steps ${grad_accu_steps} \
    --warmup-num-steps ${warmup_num_steps} \
    --use-flash-attn \
    --use-fp16 \
    --extra-fp16 \
    --use-ema \
    --resume-ema-root ${resume} \
    --ema-dtype fp32 \
    --results-dir ${results_dir} \
    --reset-loader \
    --resume \
    --resume-module-root ${resume} \
    --ckpt-every ${ckpt_every} \
    --ckpt-latest-every ${ckpt_latest_every} \
    --log-every 10 \
    --deepspeed \
    --use-zero-stage 2 \
    --gradient-checkpointing \
    --no-strict \
    --use-style-cond \
    --size-cond 1024 1024 \
    --is-inpaint \
    --is-textmask \
    --masktype inpaint  \
    "$@"
